// 文件路径：src/utils/licenseUtils.ts 或类似工具文件中
import { createHash } from 'crypto';

function md5(str: string): string {
    const hash = createHash('md5');
    hash.update(str);
    return hash.digest('hex');
}

export function generateLicenseKey(): string {
    let expiredDate = new Date();
    expiredDate.setFullYear(expiredDate.getFullYear() + 99);
    const milliSeconds = expiredDate.getTime();
    const expired = btoa(milliSeconds.toString());
    const license = `[v3][RELEASE][0102]_${expired}`;
    const hash = md5(license);
    const licenseKey = `${license}${hash}`;
    return licenseKey;
}

/*
  const crypto = require('crypto');
  function md5(str: string) {
      const hash = crypto.createHash('md5');
      hash.update(str);
      return hash.digest('hex');
  }

  let expiredDate = new Date();
  expiredDate.setFullYear(expiredDate.getFullYear() + 99);
  const milliSeconds = expiredDate.getTime();
  const expired = btoa(milliSeconds.toString());
  const license = `[v3][RELEASE][0102]_${expired}`;
  const hash = md5(license);
  const licenseKey = `${license}${hash}`;
  console.log(licenseKey);
 */
